#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
Simplified BSD License (BSD)
Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this 
      list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
      this list of conditions and the following disclaimer in the documentation 
      and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
*/
#endregion

#region Record of Change
//             							CHANGE HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | DEVELOPER  | DESCRIPTION                                              |
// -------------------------------------------------------------------------------------
// | 25-Nov-09 | HaiNM      | First creation.                                          |
// -------------------------------------------------------------------------------------
//
#endregion

#region Record of Audit
//             							REVIEW HISTORY
// -------------------------------------------------------------------------------------
// |   DATE    | REVIEWER   | NOTES                                                    |
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
//
#endregion

#region Using directives
using System;
using System.Drawing;
using System.ComponentModel;

using Thn;
#endregion

namespace Thn.Interface.Vcl
{
    /// <summary>
    /// Base class for all controls that support popups.
    /// </summary>
#if DEBUG
    public
#else
    internal
#endif
    abstract class PopupBoxBase : ControlBase
    {
        #region Fields
        /// <summary>
        /// Area where popup trigger shall be considered.
        /// </summary>
        protected Rectangle mPopupTriggerRegion = Rectangle.Empty;
        /// <summary>
        /// The user settings for popup trigger behavior.
        /// </summary>
        protected PopupTrigger mTrigger = PopupTrigger.Default;
        /// <summary>
        /// The popup trigger settings to be used when the user setting is set to default.
        /// </summary>
        protected PopupTrigger mDefaultTrigger = PopupTrigger.MouseEnter | PopupTrigger.KeyPress;
        #endregion

        #region Properties

        #region Is Popping
        private bool mIsPopping;
        /// <summary>
        /// Checks whether popup form is being shown.
        /// </summary>
        public bool IsPopping
        {
            get { return mIsPopping; }
        }
        #endregion

        #region Effective Trigger
        /// <summary>
        /// Gets the currently effective popup trigger behavior.
        /// </summary>
        public PopupTrigger EffectiveTrigger
        {
            get
            {
                PopupTrigger result = mTrigger;

                if (result == PopupTrigger.Default)
                {
                    result = mDefaultTrigger;
                }
                #region Defensive tracing
                else
                {
                    //proceed normally
                }
                #endregion

                return result;
            }
        }
        #endregion

        #endregion

        #region On Calculate Layout
        /// <summary>
        /// Perform layout calculations neccessary for this control.
        /// </summary>
        protected override void OnCalculateLayout()
        {
            base.OnCalculateLayout();
            mPopupTriggerRegion = OnCalculatePopupTriggerRegion();
        }
        #endregion

        #region On Calculate Popup Trigger Region
        /// <summary>
        /// Calculate the region for triggering popup.
        /// </summary>
        protected virtual Rectangle OnCalculatePopupTriggerRegion()
        {
            Rectangle result = new Rectangle(0, 0, Width, Height);
            return result;
        }
        #endregion

        #region Show Popup

        #endregion

        #region Cancel Popup
        #endregion

        #region Accept Popup
        #endregion

        #region Mouse Events
        #endregion

        #region Keyboard Events
        #endregion

        #region Constructors
        /// <summary>
        /// Default constructor.
        /// </summary>
        public PopupBoxBase()
        { }
        #endregion
    }
}
